package com.example.service.impl.datastatistics.yanglaofuwujigouServiceImp;

import com.example.bean.datastatistics.yanglaofuwujigou.YangLaoFuWuJiGou;
import com.example.bean.datastatistics.yanglaofuwujigou.YangLaoFuWuJiGouDuoTiaoJian;
import com.example.mapper.datastatistics.DatastatisticsMapper;
import com.example.service.datastatistics.yanglaofuwujigou.YangLaoFuWuJiGouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YangLaoFuWuJiGouServiceImp implements YangLaoFuWuJiGouService {

    @Autowired
    DatastatisticsMapper datastatisticsMapper;

    @Override
    public List<YangLaoFuWuJiGou> one(YangLaoFuWuJiGouDuoTiaoJian yangLaoFuWuJiGouDuoTiaoJian) {
      List<YangLaoFuWuJiGou> diao=datastatisticsMapper.one(yangLaoFuWuJiGouDuoTiaoJian);
        for (YangLaoFuWuJiGou yangLaoFuWuJiGou:diao) {
            if (geizhi(yangLaoFuWuJiGou.getJigouName())!=null){
                if (geizhi(yangLaoFuWuJiGou.getJigouName()).getCreditCode().substring(3,4).equals("3")){
                    System.out.println("结果："+geizhi(yangLaoFuWuJiGou.getJigouName()).getCreditCode().substring(3,4).equals("3"));
                    yangLaoFuWuJiGou.setMinban_yanglaojigoufeiyinglixing(
                            yangLaoFuWuJiGou.getMinban_yanglaojigoufeiyinglixing()
                                 !=0?0:(yangLaoFuWuJiGou.getMinban_yanglaojigoufeiyinglixing()+1));
                    System.out.println("非盈利性："+yangLaoFuWuJiGou.getMinban_yanglaojigoufeiyinglixing());
                }
                                       yangLaoFuWuJiGou.setMinban_yanglaojigouyinglixing
                                       (yangLaoFuWuJiGou.getMinban_yanglaojigouyinglixing()
                                                !=0?0:(yangLaoFuWuJiGou.getMinban_yanglaojigouyinglixing()+1));
                System.out.println("盈利性："+yangLaoFuWuJiGou.getMinban_yanglaojigouyinglixing());
            }

        }
        return diao;
    }

    @Override
    public YangLaoFuWuJiGou geizhi(String jigou_name) {

        return datastatisticsMapper.yanglaofuwujigou(jigou_name);
    }


}
